<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<img src="" alt="" id="cap1">
</body>
</html>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.1.0/jquery.js"></script>
<script>
    $(function(){
       $.get("/generate/",function(result){
             $('.captcha').attr('src', result['image_url']);
                    $('#id_captcha_0').val(result['key'])
       })
    })
</script>